let t = require;
let e = module;
let o = e.exports;
o.default = e.exports;

('use strict');
console.log('start');
var _n162,
  i =
    (this && this.__extends) ||
    ((_n162 = function n(t, e) {
      return (_n162 =
        Object.setPrototypeOf ||
        ({
          __proto__: []
        } instanceof Array &&
          function (t, e) {
            t.__proto__ = e;
          }) ||
        function (t, e) {
          for (var o in e) {
            Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
          }
        })(t, e);
    }),
      function (t, e) {
        function o() {
          this.constructor = t;
        }
        _n162(t, e),
          (t.prototype =
            null === e
              ? Object.create(e)
              : ((o.prototype = e.prototype), new o()));
      });
Object.defineProperty(o, '__esModule', {
  value: !0
}),
  (o.StoreItemCom1 = void 0);
var r = t('UIComponent'),
  a = t('AbsInfo'),
  s = t('ItemCfg'),
  c = t('ComUtils'),
  l = t('ResMrg'),
  u = t('SoundMrg'),
  h = t('BagMrg'),
  p = t('GeneralTips'),
  f = t('StoreMrg'),
  d = t('UIMrg'),
  g = t('GainPanel'),
  _ = t('GameSDK'),
  y = t('UmaSdkHelper'),
  C = t('MathUtils'),
  m = t('StoreItemColors'),
  v = t('LangCfg'),
  b = (function (t) {
    function e() {
      return (null !== t && t.apply(this, arguments)) || this;
    }
    return (
      i(e, t),
      (e.prototype.onInit = function () {
        t.prototype.onInit.call(this),
          (this._txtName = c.default.getComponent(
            cc.Label,
            this.view,
            'Background/txtName'
          )),
          (this._imgIcon = c.default.getComponent(
            cc.Sprite,
            this.view,
            'Background/imgIcon'
          )),
          (this._txtCount = c.default.getComponent(
            cc.Label,
            this.view,
            'Background/txtCount'
          )),
          (this._imgBg = c.default.getComponent(
            cc.Sprite,
            this.view,
            'Background'
          )),
          (this._ndAllPrice = c.default.getNode(
            this.view,
            'Background/ndPrice'
          )),
          (this._ndSellout = c.default.getNode(
            this.view,
            'Background/ndSellout'
          )),
          (this._ndFree = c.default.getNode(this._ndAllPrice, 'ndFree')),
          (this._ndAdFree = c.default.getNode(this._ndAllPrice, 'ndAdFree')),
          (this._ndAdFreeCount = c.default.getNode(
            this._ndAllPrice,
            'ndAdFreeCount'
          )),
          (this._txtAdCount = c.default.getComponent(
            cc.Label,
            this._ndAdFreeCount,
            'txtCount'
          )),
          (this._ndPrice = c.default.getNode(this._ndAllPrice, 'ndPrice')),
          (this._imgPriceIcon = c.default.getComponent(
            cc.Sprite,
            this._ndPrice,
            'imgIcon'
          )),
          (this._txtPrice = c.default.getComponent(
            cc.Label,
            this._ndPrice,
            'txtValue'
          )),
          (this.view.active = !0);
      }),
      (e.prototype.onLang = function () {
        var t = c.default.getComponent(
          cc.Label,
          this.view,
          'Background/ndPrice/ndFree/txtLabel'
        );
        (t.string = v.LangCfg.ins.getContent(200305)),
          ((t = c.default.getComponent(
            cc.Label,
            this.view,
            'Background/ndPrice/ndAdFree/txtLabel'
          )).string = v.LangCfg.ins.getContent(200305)),
          ((t = c.default.getComponent(
            cc.Label,
            this.view,
            'Background/ndSellout/txtLabel'
          )).string = v.LangCfg.ins.getContent(200308)),
          this.info &&
          ((this._txtName.string = v.LangCfg.ins.getContent(this._info.name)),
            (this._txtAdCount.string = v.LangCfg.ins.getContent(200306, {
              n: this.info.count
            })));
      }),
      (e.prototype.onTouchEvenHandler = function (t) {

        if (!t.currentTarget.getComponent(cc.Button).interactable) return;

        if (t.type == cc.Node.EventType.TOUCH_END)
          if (
            (u.SoundMrg.click(),
              (this.info.count > 0 && this.info.limitNum > 0) ||
              0 == this.info.limitNum)
          )
            switch (this.info.priceType) {
              case 1:
                h.BagMrg.ins.getCount(h.BagMrg.GOLD) >= this.info.price
                  ? this.buy()
                  : p.GeneralTips.notEnoughGold();
                break;

              case 2:
                h.BagMrg.ins.getCount(h.BagMrg.DIAMOND) >= this.info.price
                  ? this.buy()
                  : p.GeneralTips.notEnoughDiamond();
                break;

              case 3:
                this.info.free > 0 && this.info.count > this.info.limitNum
                  ? this.buy()
                  : _.default.videoAdBuy(
                    this.info.id,
                    v.LangCfg.ins.getContent(this._info.name),
                    this.buy,
                    this
                  );
            }
          else
            p.GeneralTips.show(
              v.LangCfg.ins.getContent(1013, {
                n: v.LangCfg.ins.getContent(this._info.name)
              })
            );
      }),
      (e.prototype.buy = function () {
        f.StoreMrg.ins.buy(this.info),
          y.default.storeBuyItem(this.info.id),
          d.UIMrg.show(g.GainPanel, [[this.info.itemId, this.info.itemCount]]);
      }),
      Object.defineProperty(e.prototype, 'info', {
        get: function get() {
          return this._info;
        },
        set: function set(t) {
          this._info != t &&
            (this._info && this._info.targetOff(this),
              t && t.on(a.InfoEvent.Changed, this.onChangedHandler, this),
              (this._info = t),
              t &&
              (l.ResMrg.loadSpriteByAtlas(
                this._imgBg,
                'Atlas/General',
                this._info.background
              ),
                this.setOutLineColor(this._info.background)),
              this.refresh());
        },
        enumerable: !1,
        configurable: !0
      }),
      (e.prototype.onChangedHandler = function () {
        this.refresh();
      }),
      (e.prototype.setOutLineColor = function (t) {
        var e = C.default.convertColor(m.StoreItemOutLineColors[t]),
          o = c.default.getComponent(
            cc.LabelOutline,
            this.view,
            'Background/txtName'
          );
        (o.color = e),
          ((o = c.default.getComponent(
            cc.LabelOutline,
            this.view,
            'Background/txtCount'
          )).color = e),
          ((o = c.default.getComponent(
            cc.LabelOutline,
            this.view,
            'Background/ndPrice/ndFree/txtLabel'
          )).color = e),
          ((o = c.default.getComponent(
            cc.LabelOutline,
            this.view,
            'Background/ndPrice/ndAdFree/txtLabel'
          )).color = e),
          ((o = c.default.getComponent(
            cc.LabelOutline,
            this.view,
            'Background/ndPrice/ndAdFreeCount/txtCount'
          )).color = e),
          ((o = c.default.getComponent(
            cc.LabelOutline,
            this.view,
            'Background/ndPrice/ndPrice/txtValue'
          )).color = e),
          ((o = c.default.getComponent(
            cc.LabelOutline,
            this.view,
            'Background/ndSellout/txtLabel'
          )).color = e);
      }),
      (e.prototype.refresh = function () {
        if (this._info) {
          // 更新文本内容
          this._txtName.string = v.LangCfg.ins.getContent(this._info.name);
          this._txtCount.string = 'x' + this._info.itemCount;
          this._txtAdCount.string = v.LangCfg.ins.getContent(200306, {
            n: this.info.count
          });
          this._txtPrice.string = this.info.price.toString();

          // 根据 limitNum 和 count 控制节点显示
          if (this.info.limitNum > 0) {
            this._ndAllPrice.active = this.info.count > 0;
            this._ndSellout.active = this.info.count < 1;
          } else {
            this._ndAllPrice.active = true;
            this._ndSellout.active = false;
          }

          // 根据 priceType 控制节点显示
          switch (this.info.priceType) {
            case 1:
            case 2:
              this._ndFree.active = false;
              this._ndPrice.active = true;
              this._ndAdFree.active = false;
              this._ndAdFreeCount.active = false;
              break;
            case 3:
              if (this.info.limitNum > 1) {
                if (this.info.count > this.info.limitNum) {
                  this._ndFree.active = true;
                  this._ndPrice.active = false;
                  this._ndAdFree.active = false;
                  this._ndAdFreeCount.active = false;
                } else {
                  this._ndFree.active = false;
                  this._ndPrice.active = false;
                  this._ndAdFree.active = false;
                  this._ndAdFreeCount.active = true;
                }
              } else {
                this._ndFree.active = false;
                this._ndPrice.active = false;
                this._ndAdFree.active = true;
                this._ndAdFreeCount.active = false;
              }
              break;
          }
          this.loadIcon();
        }
      }),
      (e.prototype.loadIcon = function () {
        if (this._info.icon)
          l.ResMrg.loadSpriteByAtlas(
            this._imgIcon,
            'Atlas/Store',
            this._info.icon
          );
        else {
          var t = s.ItemCfg.ins.getData(this._info.itemId);
          l.ResMrg.loadSpriteByAtlas(this._imgIcon, 'Atlas/Item', t.icon);
        }
        this._info.priceType < 3 &&
          (t = s.ItemCfg.ins.getData(this._info.priceType)) &&
          l.ResMrg.loadSpriteByAtlas(this._imgPriceIcon, 'Atlas/Item', t.icon);
      }),
      e
    );
  })(r.UIComponent);
(o.StoreItemCom1 = b), console.log('end');
module.exports = e.exports;
